﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Caiji.UserControls
{
    /// <summary>
    /// CheDetail.xaml 的交互逻辑
    /// </summary>
    public partial class CheDetail : UserControl
    {
        public CheDetail()
        {
            InitializeComponent();
        }

        private void Hyperlink_Click(object sender, RoutedEventArgs e)
        {
            this.detail.Visibility = Visibility.Visible;
            //动画效果(由下而上)
            ThicknessAnimation thicknessAnimation = new ThicknessAnimation(
                new Thickness(0, 50, 0, -50), //初始位置
                new Thickness(0, 0, 0, 0), //结束位置
                new TimeSpan(0, 0, 0, 0, 1000) //时间
                );
            //透明度
            DoubleAnimation doubleAnimation = new DoubleAnimation(
                0, //初始透明度
                1, //结束透明度
                new TimeSpan(0, 0, 0, 0, 4000)); //时间
            //设置动画
            Storyboard.SetTarget(thicknessAnimation, this.detailContent);
            Storyboard.SetTarget(doubleAnimation, this.detailContent);
            //设置属性
            Storyboard.SetTargetProperty(thicknessAnimation, new PropertyPath("Margin"));
            Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Opacity"));
            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(thicknessAnimation);
            storyboard.Children.Add(doubleAnimation);
            storyboard.Begin();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.detail.Visibility = Visibility.Visible;
            //动画效果(由下而上)
            ThicknessAnimation thicknessAnimation = new ThicknessAnimation(
                new Thickness(0, 0, 0, 0), //初始位置
                new Thickness( 0, 50, 0, -50), //结束位置
                new TimeSpan(0, 0, 0, 0, 1000) //时间
                );
            //透明度
            DoubleAnimation doubleAnimation = new DoubleAnimation(
                1, //初始透明度
                0, //结束透明度
                new TimeSpan(0, 0, 0, 0, 1000)); //时间
            //设置动画
            Storyboard.SetTarget(thicknessAnimation, this.detailContent);
            Storyboard.SetTarget(doubleAnimation, this.detailContent);
            //设置属性
            Storyboard.SetTargetProperty(thicknessAnimation, new PropertyPath("Margin"));
            Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Opacity"));
            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(thicknessAnimation);
            storyboard.Children.Add(doubleAnimation);
            storyboard.Completed += (se, sv) =>
            {
                this.detailContent.Visibility = Visibility.Collapsed;
            };
            storyboard.Begin();
        }
    }
}
